﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sys_t_userform.aspx.cs" Inherits="RTGS.Web.form.usermanagement.sys_t_userform" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>User Form</title>
    <link href="<%= ResolveClientUrl("~/css/validationEngine.jquery.css") %>" rel="stylesheet"
        type="text/css" />
    <script src="<%= ResolveClientUrl("~/script/helper.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveClientUrl("~/script/jquery.validationEngine.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveClientUrl("~/script/autoNumeric-1.7.5.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveClientUrl("~/script/languages/jquery.validationEngine-en.js") %>"
        type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            $('#<%=txtExpiredDays.ClientID %>').keydown(function (event) {
                // Allow: backspace, delete, tab, escape, and enter
                if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
                // Allow: Ctrl+A
            (event.keyCode == 65 && event.ctrlKey === true) ||
                // Allow: home, end, left, right
            (event.keyCode >= 35 && event.keyCode <= 39)) {
                    // let it happen, don't do anything
                    return;
                }
                else {
                    // Ensure that it is a number and stop the keypress
                    if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105)) {
                        event.preventDefault();
                    }
                }
            });

            // binds form submission and fields to the validation engine
            jQuery("#form1").validationEngine();

            //            jQuery("#form1").submit();
            if ($("#form1").validationEngine('validate')) { }
            else jQuery("#form1").submit();

            $("#save").click(function () {
                if ($("#form1").validationEngine('validate')) {
                    var user_name = $('#txtUserName').val();
                    var email = $('#txtEmail').val();
                    var mobile = $('#txtMobile').val();
                    var password = $('#txtPassword').val();
                    var expireddays = $('#txtExpiredDays').val();

                    var isactive = "0";
                    var checkIsActive = document.getElementById("chkIsActive");
                    if (checkIsActive.checked) {
                        isactive = "1";
                    }
                    else {
                        isactive = "0";
                    }

                    var islock = "0";
                    var checkIsLock = document.getElementById("chkIsLock");
                    if (checkIsLock.checked) {
                        islock = "1";
                    }
                    else {
                        islock = "0";
                    }

                    var id = $('#<%= hfID.ClientID %>').val();
                    var param = 'user_name=' + user_name + '&email=' + email + '&password=' + password + '&isactive=' + isactive + '&mobile=' + mobile + '&expireddays=' + expireddays + '&islock=' + islock;
                    if (id == 0)
                        CallAjax('<%= ResolveClientUrl("~/ajaxhandler/usermanagement/sys_t_user.ashx") %>', '?method=insert&' + param);
                    else {

                        CallAjax('<%= ResolveClientUrl("~/ajaxhandler/usermanagement/sys_t_user.ashx") %>', '?method=update&' + param + '&id=' + id);
                    }
                    parent.$('#dialog').dialog('close');
                    setTimeout("parent.$('#table').trigger('reloadGrid');", 3000);

                }
                return false;
            });

        });
    </script>
    <script type="text/javascript">

        function ClearText() {

            $('#txtUserName').val('');
            $('#txtEmail').val('');
            $('#txtMobile').val('');
            $('#txtPassword').val('');
        }

        $('#close').click(function () {
            parent.$('#dialog').dialog('close');
        });
         
    </script>
</head>
<body onload="ClearText();">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="scManager" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="updt" UpdateMode="Conditional" runat="server">
    </asp:UpdatePanel>
    <table border="0">
        <tr>
            <td style="width: 50">
                User Name
            </td>
            <td>
                :
            </td>
            <td>
                <asp:TextBox ID="txtUserName" CssClass="validate[required]" runat="server" Width="300"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width: 50">
                Email
            </td>
            <td>
                :
            </td>
            <td>
                <asp:TextBox ID="txtEmail" runat="server" Width="300"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width: 50">
                Mobile
            </td>
            <td>
                :
            </td>
            <td>
                <asp:TextBox ID="txtMobile" runat="server" Width="300"></asp:TextBox>
            </td>
        </tr>
        <tr id="trPassword" runat="server">
            <td style="width: 50">
                Password
            </td>
            <td>
                :
            </td>
            <td>
                <asp:TextBox ID="txtPassword" CssClass="validate[required]" runat="server" TextMode="Password" Width="300"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width: 50">
                Expired Days
            </td>
            <td>
                :
            </td>
            <td>
                <asp:TextBox ID="txtExpiredDays" CssClass="validate[required]" runat="server" Width="80"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width: 50">
                IsLock
            </td>
            <td>
                :
            </td>
            <td>
                <asp:CheckBox ID="chkIsLock" runat="server" />
            </td>
        </tr>
        <tr>
            <td style="width: 50">
                IsActive
            </td>
            <td>
                :
            </td>
            <td>
                <asp:CheckBox ID="chkIsActive" runat="server" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                &nbsp;
            </td>
            <td>
                <div style="text-align: right; padding-top: 10px;">
                    <a href="#" id="save" class="dialog_link ui-state-default ui-corner-all" alt="Save">
                        <span class="ui-icon ui-icon-disk"></span>Save</a> <a href="#" id="close" class="dialog_link ui-state-default ui-corner-all"
                            alt="Close" onclick="parent.$('#dialog').dialog('close');"><span class="ui-icon ui-icon-close">
                            </span>Close</a>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                &nbsp;
            </td>
            <td>
                <asp:HiddenField ID="hfID" runat="server" />
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
